// console.log(location.search)
const id = location.search.split('?id=')[1]
console.log(id);
  
; (async function () {
  const {data}  = await axios.get(`/index/show?id=${id}`)
  
    console.log(data)
  document.querySelector('.content').innerHTML = `
     <header class="article-header">
            <!-- 面包屑 -->
            <div class="breadcrumbs">
              <span class="text-muted">当前位置：</span>
              <a href="">优点达资讯</a>
              <small>></small> 
              <a href="">${data.data.info.catename}</a> <small>></small> 
              <span class="text-muted">${data.data.info.description}</span>
            </div>
            <!-- 标题 -->
            <h1 class="article-title"><a href="">${data.data.info.title}</a></h1>
            <!-- 标题描述 -->
            <ul class="article-meta">
              <li><a href="">${data.data.info.author}</a> 发布于 ${new Date (data.data.info.creat_date)}</li>
              <li>分类：<a href="" rel="category tag">奇·趣事</a></li>
              <li><span class="post-views">阅读(4672)</span></li>
              <li>评论(1)</li>
              <li></li>
            </ul>
          </header>
          <!-- 广告位 -->
          <div class="ssr ssr-content ssr-post">
            <center>
              <a href="" title="" target="_blank" rel="nofollow">
                <img src="static/images/default.png" style="width: 728px;height:90px;" alt="">
              </a>
            </center>
          </div>
          <!-- 文章正文 -->
          <article class="article-content">
            <!-- 文章内容开始 -->
              <p>
                ${data.data.info.content}
              </p>
              <!-- 文章内容结束 -->
              
              <!-- 版权描述 -->
              <p class="post-copyright">未经允许不得转载：
              <a href="">优点达资讯</a> &raquo; <a href="">金戈铁马－骑着单车去打仗的二战德国国防军</a></p>
          </article>
          <!-- 点赞 -->
          <div class="article-social">
            <a href="javascript:;" class="action action-like" >
              <i class="glyphicon glyphicon-thumbs-up"></i>赞 (<span>${data.data.info.lovenum}</span>)
            </a> 
          </div>
          <!-- 标签信息 -->
          <div class="article-tags">
            标签：<a href="" rel="tag">${data.data.info.tag}</a> 
          </div>
          <!-- 上下一篇 -->
          <nav class="article-nav">
            <span class="article-nav-prev">
              <span>上一篇</span>
              <a href="" rel="prev">running dogs 绝佳狗狗奔跑慢镜</a>
            </span>
            <span class="article-nav-next">
              <span>下一篇</span>
              <a href="" rel="next">玩味户外，OYO Mountain Products 2013 秋冬系列</a>
            </span>
          </nav>
          <!-- 广告位 -->
          <div class="ssr ssr-content ssr-related">
            <center>
              <a href="" rel="nofollow" title="" target="_blank">
                  <img src="static/images/default.png" style="width: 728px;height:90px;" alt="">
              </a>
            </center>
          </div>
          <div class="relates relates-model-thumb">
            <h3 class="title"><strong>相关推荐</strong></h3>
            <ul>
              <li>
                <a target="_blank" href="">
                  <span>
                    <img src="./static/images/default.png" class="thumb" />
                  </span>
                  范佩西化身各路英雄
                </a>
              </li>
              <li>
                <a target="_blank" href="">
                  <span>
                    <img src="./static/images/default.png" class="thumb" />
                  </span>
                  范佩西化身各路英雄
                </a>
              </li>
              <li>
                <a target="_blank" href="">
                  <span>
                    <img src="./static/images/default.png" class="thumb" />
                  </span>
                  范佩西化身各路英雄
                </a>
              </li>
              <li>
                <a target="_blank" href="">
                  <span>
                    <img src="./static/images/default.png" class="thumb" />
                  </span>
                  范佩西化身各路英雄
                </a>
              </li>
             
            </ul>
          </div> 
     
   
    `

  
})()
     ; (async function () {
        const { data: { data } } = await axios.get('/index/index')
        // console.log(data)
        // ==========================================1.导航列表=========================================
        const navStr = data.allCate.map(item => `
    <li onclick="capture(${item.id})"  class="menu-item menu-item-type-taxonomy menu-item-object-category" data-id=${item.id}><a href="list.html"><span
        class="fa ${item.icon}"></span>${item.catename}</a></li>
    `).join('')
        $(".nav").append(navStr)
        // =========================================2.导航右侧广告=======================================
        // console.log(data.sideBanner);
        const advStr = data.sideBanner.map(item => `
    <a href="${item.advimglink}" rel="nofollow" target="_blank" title="${item.advimgdesc}">
      <img class="g430" style="width:360px;height:133px;" src="http://124.223.14.236:8060/${item.advimgsrc}" alt="${item.advimgdesc}" >
    </a>
    `).join('')
        $(".textwidget").html(advStr)
        // ===========================================3.标签列表========================================
        // console.log(data.allTag)
        const tagStr = data.allTag.map(item => `
    <li data-id=${item.id}><a title="" href="">${item.tagname}</a></li>
    `).join('')
        $("#tags").html(tagStr)
        // ==========================================4.友情链接=========================================
        // console.log(data.allLink)
        const linksStr = data.allLink.map(item => `
    <li>
      <a href="${item.url}"><img src="http://124.223.14.236:8060/${item.img}" alt=""><p>${item.des}</p></a>
    </li>
    `).join('')
        $("#links").html(linksStr)
        
        // ===========================================6.底部链接============================================
        // console.log(data.allLink);
        const linkBtm = data.allLink.map(item => `
        <a href="${item.url}" title="${item.des}">${item.des}</a> <span>|</span>
        `).join('')
        $(".link").html(linkBtm)
    })()
    // ==============================================热门推荐============================================
    ; (async function () {
        const { status, data: { data } } = await axios.get('/index/hot')
        // console.log(data.list)
        const hotStr = data.list.map(({ title, pic, id }) =>
            `<li class="item" data-id=${id}><a target="_blank" href="show.html?${id}" class"remen"><img src="http://124.223.14.236:8060/${pic}" class="thumb" style='width:100%'/>${title}</a></li>`
        ).join('')
        $('#hot').html(hotStr)
    })()


    // =============================================侧边热门文章============================================
    ; (async function () {
        const { status, data: { data } } = await axios.get('/index/recommend')
        const hotArt = data.list.map(item => `
        <li data-id=${item.id}>
            <a target="_blank" href="">
                <span class="thumbnail">
                    <img src="http://124.223.14.236:8060/${item.pic}" class="thumb" />
                </span>
                <span class="text">${item.title}</span>
                <span class="text-muted post-views">阅读(${item.click})</span>
            </a>
        </li>
    `).join('')
        $(".items-02").html(hotArt)

    })()
